let { db } = require('../tools')
module.exports = (req, res) => {
    db.collection('user')
        // .insertOne(req.body)
        .findOne(req.body)
            .then(data => {
                req.session.username = req.body.username
                if(data) {
                    res.json({errno: 0, msg: '登陆成功', username:data.username})
                }
            })
            .catch(err => res.json({errno: 1}))
            
}